<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
		<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
		<html>
		<head>
			<title>账号管理</title>
			<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
			<jsp:include page="/WEB-INF/views/include/newhead.jsp" />
		</head>
		<body class="childrenBody site-block">
			<header class="larry-personal-tit">
				<span>
				    <!-- contentAccount 将user对应替换 -->
					<c:if test="${empty contentAccount.id}">新增</c:if>
					<c:if test="${not empty contentAccount.id}">修改</c:if>
				</span>
			</header>
			
			<div class="mainCon">
				<form:form id="inputForm" autocomplete="off" modelAttribute="contentAccount" action="${ctx}/content/contentAccount/save" method="post">
					<form:hidden path="id"/>
					<sys:message content="${message}"/>
					
							<div class="layui-form-item">
							   <div class="layui-inline">
									<label class="layui-form-label"><font color="red">*</font>登录账号</label>
									<div class="layui-input-inline">
											<form:input path="account" placeholder="请输入登录账号"  maxlength="50" class="layui-input required"/>
									</div>
							   </div>
							   
							    <div class="layui-inline">
									<label class="layui-form-label"><font color="red">*</font>密码</label>
									<div class="layui-input-inline">
										<form:input path="password" placeholder="请输入密码"  maxlength="50" class="layui-input required"/>
									</div>
							   </div>
							</div>
							
							<div class="layui-form-item">
							    <label class="layui-form-label"><font color="red">*</font>所属平台</label>
							  	<div class="layui-input-inline layui-input-inline-one">
								     <div class="checkbox icheck-nephritis checkbox-extend">
										<input type="checkbox" name="platform" value="1" id="dy" />
										<label for="dy">抖音</label>
			                          </div>
			                          <div class="checkbox icheck-nephritis checkbox-extend">
										<input type="checkbox" name="platform" value="2" id="ks" />
										<label for="ks">快手</label>
			                         </div>
			                         <div class="checkbox icheck-nephritis checkbox-extend">
										<input type="checkbox" id="xhs" name="platform" value="3" />
										<label for="xhs">小红书</label>
			                         </div>
								</div>
							</div>
							<div class="layui-form-item">
							   <div class="layui-inline">
									<label class="layui-form-label">备注信息</label>
									<div class="layui-input-inline layui-input-inline-one">
											<form:textarea path="remarks" placeholder="请输入备注信息" htmlEscape="false" rows="4" maxlength="255" class="layui-textarea"/>
									</div>
							   </div>
							</div>
					
					<div class="layui-form-item bottom_xf">
						<div class="layui-input-block input500">
							<button type="button" class="layui-btn layui-btn-primary" onclick="gotoView('${ctx}/content/contentAccount/');">返回</button>
							<button class="layui-btn" type="submit">保存</button>
							<button onclick="formReset();" type="button"  class="layui-btn layui-btn-danger">重置</button>
						</div>
					</div>
				</form:form>
			</div>

            <jsp:include page="/WEB-INF/views/include/pageJs.jsp" />
			
			<script type="text/javascript">
				$(document).ready(function() {
					$("#inputForm").validate({
						submitHandler: function(form){
							var platform = $('input[name="platform"]:checked').val(); 	
							if(platform == undefined){
								top.$.jBox.tip('请勾选所属平台!','error');  
								return;
							}
							loading('正在提交，请稍等...');
							form.submit();
						},
						errorContainer: "#messageBox",
						errorPlacement: function(error, element) {
							$("#messageBox").text("输入有误，请先更正。");
							if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
								error.appendTo(element.parent().parent());
							} else {
								error.insertAfter(element);
							}
						}
					});
					
					initPlatform();
				});
				
				function initPlatform(){
					var platform = "${contentAccount.platform}";
					
					var arr = platform.split(",");
					for(j = 0,len=arr.length; j < len; j++) {
					    if(arr[j] == "1"){
					    	$("#dy").prop("checked",true);
					    }else if(arr[j] == "2"){
					    	$("#ks").prop("checked",true);
					    }else if(arr[j] == "3"){
					    	$("#xhs").prop("checked",true);
					    }
					}
				}
				
			</script>
		</body>
		</html>